package tetrisbattle;

import java.awt.Dimension;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;

/**
 *
 * @author Rick Jason G. Obrero
 */
public class TetrisBattle extends TetrisBattleGrid{
    public TetrisBattle(){
        super(20, 10);
        this.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent arg0) {
                if(arg0.getKeyCode() == KeyEvent.VK_LEFT){
                    JOptionPane.showMessageDialog(null, "Left key pressed.");
                }else if(arg0.getKeyCode() == KeyEvent.VK_RIGHT){
                    JOptionPane.showMessageDialog(null, "Right key pressed.");
                }else if(arg0.getKeyCode() == KeyEvent.VK_DOWN){
                    JOptionPane.showMessageDialog(null, "Down key pressed.");
                }else if(arg0.getKeyCode() == KeyEvent.VK_SPACE){
                    JOptionPane.showMessageDialog(null, "Space key pressed.");
                }else if(arg0.getKeyCode() == KeyEvent.VK_Z){
                    JOptionPane.showMessageDialog(null, "Z key pressed.");
                }else if(arg0.getKeyCode() == KeyEvent.VK_ESCAPE){
                    JOptionPane.showMessageDialog(null, "Escape key pressed.");
                }
            }
        });
    }
    
    public void addFirstRow(int[] firstRow){
        for(int i = 0; i < this.cols; i++){
            int j = dimToInt.get(new Dimension(0, i));
            intToBrick.put(j, firstRow[i]);
        }
        changeColor();
    }
}
